<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>加入我们</title>
    <asset:stylesheet src="style.css" media="screen"/>
    <asset:stylesheet src="htmleaf-demo.css"/>
    <asset:stylesheet src="myAlert.min.css"/>
    <asset:javascript src="jquery1.8.3.js"/>
    <asset:javascript src="jquery-1.11.0.min.js"/>
    <asset:javascript src="jquery.form.js"/>
    <asset:javascript src="jquery-form.js"/>
    <asset:javascript src="js.js"/>
    <asset:javascript src="myAlert.min.js"/>
    <script type="text/javascript">
        function checkphone() {
            var length = $('.call_txt').val().length;
            var flag = false
            var a = document.getElementById("phone").value
            if ($(".call_txt").val() == "") {
                $(".call_txt").next("span").css("color", "red");
                $(".call_txt").next("span").html("联系方式不能为空，请填写您的联系方式！");
            }
            else if (length != 8 && length != 11) {
                $(".call_txt").next("span").css("color", "red");
                $(".call_txt").next("span").html("您输入的联系方式有误，请重新输入！");
            }
            else if (!(/^1[35789]\d{9}$/.test(a))) {
                $(".call_txt").next("span").css("color", "red");
                $(".call_txt").next("span").html("您输入的联系方式有误，请重新输入！");
            }
            else {
                $(".call_txt").css("border", "solid 1px #d8d8e6");
                $(".call_txt").next("span").html("√");
                $(".call_txt").next("span").css("color", "#20a925");
                flag = true
            }
            return flag
        }

        function checkmail() {
            var a = document.getElementById("ma").value
            var myreg = /^([\.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
            var flag = false
            if ($(".mail_txt").val() == "") {
                $(".mail_txt").next("span").css("color", "red");
                $(".mail_txt").next("span").html("邮箱不能为空，请填写您的邮箱！");
            }
            else if (!myreg.test(a)) {
                $(".mail_txt").next("span").css("color", "red");
                $(".mail_txt").next("span").html("您输入的邮箱有误，请重新输入！");
            }
            else {
                $(".mail_txt").css("border", "solid 1px #d8d8e6");
                $(".mail_txt").next("span").html("√");
                $(".mail_txt").next("span").css("color", "#20a925");
                flag = true
            }
            return flag
        }

        function creatrand() {
            document.getElementById("cfi_code").src = "${grailsApplication.config.address.url}/user/getCode?number=" + Math.random()
        }

        $(document).ready(function () {
            %{--var a = <%=data%>--}%
            %{--alert(a)--}%
//            $.post("/jobb/getBy", {id: a});

            var options = {
                success: function (data) {
                    console.log(data)

                }
            };

            $("#information_content").ajaxForm(options);
            $("#information_content").submit(function () {
                if (checkphone() && checkmail()) {
                    var value = window.document.getElementById("code").value
                    $.ajax({
                        url: "/user/checkCode",
                        data: {code: value},
                        async: false,
                        type: "post",
                        success: function (data) {
                            var a = $("input[type=file]").val()
                            if (data.data == "0") {
                                $("#information_content").ajaxSubmit({
                                    success: function (data) {
                                        $.myAlert("感谢您的投递，我们将尽快联系您");
                                        creatrand();
                                    },
                                    error: function (error) {
                                        $.myAlert("提交失败,稍后再试试喔");
                                    },
                                    url: '/apply/add', /*设置post提交到的页面*/
                                    type: "post", /*设置表单以post方法提交*/
                                    dataType: "json", /*设置返回值类型为文本*/
                                    resetForm: "true"
                                });
                            } else {
                                alert("验证码错误")
                                creatrand()
                            }
                        }
                    });
                }
            });
        })

    </script>
</head>

<body onload="creatrand()">
<div class="header">
    <g:link controller="user" action="index"><g:img dir="images" file="logo.png" class="logo_img"/></g:link>
    <ul class="nav_ul">
        <li><g:link controller="user" action="index">首页</g:link></li>
        <li><g:link controller="user" action="solution">解决方案</g:link></li>
        <li><g:link controller="user" action="about">关于颐瑞</g:link></li>
        <li class="active_li"><g:link controller="user" action="join">加入我们</g:link></li>
    </ul>
</div>

<div class="information_details">
    <div class="information_title">填写个人信息<br>
        <span>请如实填写个人信息。</span></div>

    <form class="information_content" onsubmit="return false" id="information_content">
        <span class="information_content_left left_content" id="post">申请岗位：</span>

        <div class="right_content" id="position" style="line-height: 45px;">${data}</div>
        <input type="hidden" value="${data}" name="job"/>
        <span class="information_content_left left_content" id="name">姓名：</span>

        <div class="right_content" id="name_txt">
            <input name="username" type="text" class="name_txt" placeholder="姓名" minlength="2" maxlength="8"
                   autocomplete="off">
            <span class="right_content_txt"></span>
        </div>
        <span class="information_content_left left_content" id="sex">性别：</span>

        <div class="right_content" id="sex_rdo">
            <input type="radio" name="sex" id="radio1" value="0" checked>
            <label for="radio1" class="rdo">男</label>
            <input type="radio" name="sex" id="radio2" value="1">
            <label for="radio2" class="rdo">女</label>
        </div>
        <span class="information_content_left left_content" id="education">学历：</span>

        <div class="right_content" id="edu_slt">
            <select class="slt_edu" id="slt_edu" name="education">
                %{--<option value="请选择学历">请选择学历</option>--}%
                <option value="大专">大专</option>
                <option value="本科" selected>本科</option>
                <option value="硕士">硕士</option>
                <option value="博士">博士</option>
            </select>
        </div>
        <span class="information_content_left left_content" id="call">联系方式：</span>

        <div class="right_content" id="call_txt">
            <input name="phone" type="text" class="call_txt" placeholder="联系方式" autocomplete="off" id="phone"
                   maxlength="11">
            <span class="right_content_txt"></span>
        </div>
        <span class="information_content_left left_content" id="mail">邮箱：</span>

        <div class="right_content" id="mail_txt">
            <input name="mail" type="text" class="mail_txt" placeholder="邮箱" autocomplete="off" id="ma" maxlength="32">
            <span class="right_content_txt"></span>
        </div>
        <span class="information_content_left left_content_file" id="file">上传资料：</span>

        <div class="right_content_file" id="pic_file"><input name="filePath" type="file" class="file" id="files"
                                                             required></div>


        <span class="information_content_left left_content_file" id="yzm">验证码：</span>

        <div class="right_content" id="check_yzm">
            <input type="text" class="yzm_txt" placeholder="验证码" autocomplete="off" name="code" id="code"
                   minlength="4" maxlength="4" required>

            <img id="cfi_code" class="rand"
                 src="${grailsApplication.config.address.url}/user/getCode?number=${Math.random()}"
                 onclick="creatrand()"/>
        </div>

        <div class="information_tail">
            <input type="submit" class="btn_submit" value="信息确认无误，提交申请">
        </div>
        <input type="reset" style="display:none;"/>
    </form>
</div>
</div>

<div class="footer">
    <div class="footer_content">
        <div class="footer_left">
            <g:img dir="images" file="erweima.jpg" class="footer_img"/><br/>

            <p>扫描二维码关注颐瑞科技微信公共号</p>
        </div>

        <div class="footer_right">
            <p><a href="http://www.miitbeian.gov.cn/">Copyright&nbsp;©&nbsp;2017&nbsp;颐瑞科技&nbsp;版权所有&nbsp;浙ICP备17050944号</a>
            </p>
        </div>
    </div>
</div>
<script>
    var _hmt = _hmt || [];
    (function () {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?cfe87f0a72b395c8c4eb3b7aa52cea65";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
</script>
</body>
</html>